-
Notifications
You must be signed in to change notification settings - Fork 619
[SDK] feat: Add session key update handling and expose utility #6217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SDK] feat: Add session key update handling and expose utility #6217
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
🦋 Changeset detectedLatest commit: f42af42 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
size-limit report 📦
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6217 +/- ##
==========================================
+ Coverage 56.72% 56.78% +0.05%
==========================================
Files 1161 1161
Lines 64289 64342 +53
Branches 5196 5219 +23
==========================================
+ Hits 36468 36535 +67
+ Misses 27095 27079 -16
- Partials 726 728 +2
*This pull request uses carry forward flags. Click here to find out more.
|
| if ( | ||
| !areSessionKeyContractTargetsEqual( | ||
| currentPermissions.approvedTargets, | ||
| newPermissions.approvedTargets, | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of checking for equality, it could check for subests to minimize the need for creating sessions (i.e., currentPermissions.approvedTargets includes at least all of newPermissions.approvedTargets)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Looks great
| if ( | ||
| currentPermissions.nativeTokenLimitPerTransaction !== | ||
| toWei(newPermissions.nativeTokenLimitPerTransaction?.toString() ?? "0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again instead of equality, this could be currentPermissions.nativeTokenLimitPerTransaction >= newPermissions.nativeTokenLimitPerTransaction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| * @param newPermissions - The new permissions to set for the session key. | ||
| * @returns A boolean indicating if the session key should be updated. | ||
| */ | ||
| export async function shouldUpdateSessionKey(args: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also check on startDate and isAdmin values in our current version of this logic, but not sure if that's important here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
start date is a bit weird, decided to leave it alone for this. And yeah admin should be separate i think?
004598e to
f42af42
Compare

Fixes #6203
PR-Codex overview
This PR focuses on enhancing session key management in the
thirdweblibrary by adding a new function,shouldUpdateSessionKey, which determines if a session key's permissions should be updated based on various conditions.Detailed summary
shouldUpdateSessionKeyfunction inpackages/thirdweb/src/extensions/erc4337/account/addSessionKey.ts.connectSmartAccountfunction to utilizeshouldUpdateSessionKeyfor session key checks.shouldUpdateSessionKeywhere necessary.shouldUpdateSessionKeyinpackages/thirdweb/src/extensions/erc4337/account/permissions.test.ts.